package me.zhengjie.modules.system.service.dto

import cn.hutool.core.bean.BeanUtil
import cn.hutool.core.bean.copier.CopyOptions
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeName
import me.zhengjie.common.base.BaseDTO
import me.zhengjie.common.utils.JacksonUtil
import org.apache.commons.lang3.builder.ToStringBuilder
import java.sql.Timestamp
/**
 * @author Kuki Wu
 * @date 2019-04-10
 */

@JsonTypeName("DictDetailDTO")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
data class DictDetailDTO(
    var id: Long? = null,
    var dict:DictSmallDto? = null,
    var label: String? = null,
    var value: String? = null,
    var dictSort: String? = null
): BaseDTO(){
    annotation class Update

    companion object {
        fun fromJson(json: String): DictDetailDTO? {
            val obj=JacksonUtil.parseObject(json, DictDetailDTO::class.java)!!
            return when(obj){
                is DictDetailDTO -> obj
                else -> null
            }
        }
    }

    fun copy(source: DictDetailDTO?) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true))
    }
}